package com.netty.modbus.dto.request;

import com.netty.modbus.exception.DataConvertException;
import com.netty.modbus.util.HexUtil;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;

/**
 * description: CommonBody <br>
 * date: 2021/10/18 11:57 <br>
 * @author: lwy <br>
 * version: 1.0 <br>
 */
public class CommonBody extends RequestBody{
    private final String devNumber;
    private final String commonCommandHex;

    public CommonBody(String devNumber, String commonCommandHex) {
        this.devNumber = devNumber;
        this.commonCommandHex = commonCommandHex;
    }



    @Override
    public ByteBuf encode() throws DataConvertException {
        ByteBuf dataBuf= Unpooled.buffer();
        dataBuf.writeBytes(HexUtil.hexToBytes(this.commonCommandHex));
        return dataBuf;
    }
}
